<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> 
<c:set var="ctx" value="${pageContext.request.contextPath}/" /> 
<!--遮罩层-个人信息-->
<div class="wrapper">
	<div class="mask">
		<div class="mask-head">
			<a href="javascript:;" class="mask-close"></a><fmt:message key='Personal.information'/>
		</div>
		<div class="mask-content">
			<div class="inputbox">
				<div class="proname">
					<i class="logo-name"></i><fmt:message key='Login.name'/>：
				</div>
				<div class="procontent">
					<input type="text" name="foot_username" readonly="readonly" class="wpinput num" value="" maxlength="20">
				</div>
			</div>
			<div class="inputbox">
				<div class="proname">
					<i class="mail-icon"></i><fmt:message key='email'/>：
				</div>
				<div class="procontent">
					<input type="text" name="foot_email" readonly="readonly" class="wpinput num" value="" maxlength="30">
				</div>
			</div>
			<div class="inputbox">
				<div class="proname">
					<i class="phone-icon"></i><fmt:message key='Mobile.phone'/>：
				</div>
				<div class="procontent">
					<input type="text" name="foot_mobile" readonly="readonly" class="wpinput num" value="" maxlength="20">
				</div>
			</div>
			<div class="inputbox">
				<div class="proname">
					<i class="zhuangtai"></i><fmt:message key='status'/>：
				</div>
				<div class="procontent">
					<div class="out">
						<input type="text" name="foot_status" readonly="readonly" class="wpinput num" value="" maxlength="20">
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<!--遮罩层-修改密码-->
<div class="wrapper2">
	<div class="mask">
		<div class="mask-head">
			<a href="javascript:;" class="mask-close2"></a><fmt:message key='Change.the.password'/>
		</div>
		<div class="mask-content">
			<div class="inputbox">
				<div class="proname">
					<i class="icon-pass"></i><fmt:message key='The.original.password'/>：
				</div>
				<div class="procontent">
            		<input class="wpinput" name="pwd_password" type="password"  placeholder="" value=""  maxlength="20"/>
				</div>
			</div>
			<div class="inputbox">
				<div class="proname">
					<i class="icon-pass2"></i><fmt:message key='New.Password'/>：
				</div>
				<div class="procontent">
            		<input class="wpinput" name="pwd_passwordNew" type="password"  placeholder="" value=""  maxlength="20"/>
				</div>
			</div>
			<div class="inputbox">
				<div class="proname">
					<i class="icon-pass2"></i><fmt:message key='Reset.the.new.password'/>：
				</div>
				<div class="procontent">
           			<input class="wpinput" name="pwd_passwordNewRepet" type="password"  placeholder="" value=""  maxlength="20"/>
				</div>
			</div>
			<div class="xiugai">
				<button class="orange2"  onclick="validateResetPwdForm()"><fmt:message key='Modify.the'/></button>
			</div>
			<div class="xiugai error pwd_error"></div>
		</div>
	</div>
</div>
<script type="text/javascript">
function validateResetPwdForm(){
	debugs("in reset pwd validateResetPwdForm");
	var pwd_password = $("input[name='pwd_password']").val();
    if(empty(pwd_password)){
    	$('.pwd_error').html("<fmt:message key='Please.enter.the.original.password'/>");  
		return false;
    }
    if(pwd_password.length<6){
    	$('.pwd_error').html("<fmt:message key='password.length.incorrectss'/>");  
		return false;
    } 
	var pwd_passwordNew = $("input[name='pwd_passwordNew']").val();
    if(empty(pwd_passwordNew)){
    	$('.pwd_error').html('<fmt:message key='Please.enter.a.news.password'/>');
		return false;
    }
    if(pwd_passwordNew.length<6){
    	$('.pwd_error').html('<fmt:message key='password.length.incorrectss'/>');
		return false;
    }
	var pwd_passwordNewRepet = $("input[name='pwd_passwordNewRepet']").val();
    if(empty(pwd_passwordNewRepet)){
    	$('.pwd_error').html('<fmt:message key='Please.enter.the.repeat.news.password'/>');
		return false;
    }
    if(pwd_passwordNewRepet !=pwd_passwordNew){
    	$('.pwd_error').html('<fmt:message key='Passwords.dont.match'/>');
		return false;
    }
    var json={};
	json.password=pwd_password;
	json.passwordNew=pwd_passwordNew;
	json.passwordNewRepet=pwd_passwordNewRepet;

	debugs("in reset pwd json:");
	//debugs(json);
    //ajax submit ${ctx}admin/adminuser/resetpwd
	$.ajax({
		url:'${ctx}admin/adminuser/resetpwd',
		type: 'POST', 
		contentType: "application/json",
		data: JSON.stringify(json),
		dataType:'json',
		success:function(result){ 
			if(result.flag){
		    	$('.pwd_error').html('<fmt:message key='Change.the.password.successfully'/>');
		    	//debugs("change pwd ok"); 
		    	setTimeout('hiddenPwd()', 3000);
		    	//debugs("change pwd done");
			}else{
		    	$('.pwd_error').html(result.msg);
			}
		},
		error:function(){ 
	    	$('.pwd_error').html('<fmt:message key='Change.the.password.failure'/>'); 
		}
	}); 
}

function hiddenPwd(){
	$(".wrapper2").css("display","none");
	$("input[name='pwd_password']").val("");
    $("input[name='pwd_passwordNew']").val("");
    $("input[name='pwd_passwordNewRepet']").val("");
	$('.pwd_error').html("");
}

$(function(){ 
	//左侧列表
	/*$(".listul-div").toggle(function(){
		$(this).parents(".listul-li").find(".listul-mask").css("display","block");
		$(this).find(".list-arrow").css("background","url('${ctx}assets/assetadmin/images/jianhao_icon.png') 0px 33px no-repeat");
	},function(){
		$(this).parents(".listul-li").find(".listul-mask").css("display","none");
		$(this).find(".list-arrow").css("background","url('${ctx}assets/assetadmin/images/jiahao_icon.png') 0px 25px no-repeat");
	});*/
	
	$(".listul-div").click(function(){
		$(this).find('.list-arrow').toggleClass("s").parents('.listul-li').siblings('.listul-li').find('.list-arrow').removeClass("s");
		$(this).parents("p").siblings('.listul-mask').slideToggle().parents('.listul-li').siblings('.listul-li').children('.listul-mask').hide();
	})
	
	$(".listul-mask li").mouseover(function(){
		$(this).find(".dot").css("visibility","visible");
	});
	$(".listul-mask li").mouseout(function(){
		$(this).find(".dot").css("visibility","hidden");
	}); 
	//弹出框
	$(".top-nav").find("li").eq(1).click(function(){ 
		$.ajax({
			url:'${ctx}admin/adminuser/info',
			type: 'POST', 
			contentType: "application/json",
			dataType:'json',
			success:function(result){ 
				if(result.flag){
					setUserInfo(result.map);
					showUserInfo();
				}else{}
			},
			error:function(){ }
		});
	})
	
	$(".mask-close").click(function(){
		resetUserInfo();
		hiddenUserInfo();
	})
	
	//展示用户信息
	function showUserInfo(){
		$(".wrapper").css("display","block");
	}
	
	//关闭用户信息
	function hiddenUserInfo(){
		$(".wrapper").css("display","none");
	}

	//设置用户信息
	function setUserInfo(jsonData){
		$("input[name='foot_username']").val(jsonData.username);  
		$("input[name='foot_email']").val(jsonData.email);  
		$("input[name='foot_mobile']").val(jsonData.mobile);  
		$("input[name='foot_status']").val(jsonData.status); 
	}
	
	//重置用户信息
	function resetUserInfo(){
		$("input[name='foot_username']").val("");  
		$("input[name='foot_email']").val("");  
		$("input[name='foot_mobile']").val("");  
		$("input[name='foot_status']").val(""); 
	}
	
	$(".top-nav").find("li").eq(2).click(function(){
		$(".wrapper2").css("display","block");
	})
	$(".mask-close2").click(function(){
		$(".wrapper2").css("display","none");
	})
})


// 通用的编辑方法
function mod(id) {
  window.location.href = "${baseUrl}edit/" + id
}

function rowResetUser(ids) {
  window.location = '${baseUrl}view?ids=' + ids;
}

// 通用的删除方法
function del(id) {
  var setIds = [];
  setIds.push(id);
  layer.confirm('确定要删除该条数据？', {
    btn : [ '确定', '取消' ],
    btn2 : function(index, layero) {
      layer.close(index);
    },
    title : [ '删除提示', true ]
  }, function(index, layero) {
    rowDelete(setIds);
  });
}

function rowDelete(id) {
  debugs(id);
  $.ajax({
    url : "${baseUrl}remove",
    type : 'POST',
    contentType : "application/json",
    dataType : 'json',
    data : JSON.stringify({
      "ids" : id
    }),
    success : function(data) {
      debugs(data);
      if (data != null && data.flag) {
        layer.alert('删除成功', {
          icon : 1,
          skin : 'layer-ext-moon',
          closeBtn : 0
        }, function() {
          $('#listForm').submit();
        });
      } else {
        alertError('删除失败');
      }
    }
  });
}
</script>
